package com.dc.service.dto.electronic;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseResult<T> implements Serializable {

    @JsonProperty("IsSuccess")
    private Boolean IsSuccess;

    @JsonProperty("Code")
    private String Code;

    @JsonProperty("Msg")
    private String Msg;

    @JsonProperty("Content")
    private T Content;

    @JsonProperty("Remark")
    private String Remark;

    @JsonProperty("Count")
    private Integer Count;

    public ResponseResult() {

    }

    public ResponseResult(Boolean isSuccess, String code, String msg, T content) {
        IsSuccess = isSuccess;
        Code = code;
        Msg = msg;
        Content = content;
    }

    public static ResponseResult success() {
        return success(null);
    }

    public static <T> ResponseResult<T> success(T data) {
        return success(ResultStatusCode.OK.getEnMsg(), data);
    }

    public static <T> ResponseResult<T> success(String msg, T data) {
        return new ResponseResult(true, ResultStatusCode.OK.getCode() + "", msg, data);
    }

    public static ResponseResult error() {
        return error(ResultStatusCode.SYSTEM_ERR.getCode() + "",
                ResultStatusCode.SYSTEM_ERR.getEnMsg());
    }

    public static ResponseResult error(String msg) {
        return error(ResultStatusCode.SYSTEM_ERR.getCode() + "", msg);
    }

    public static ResponseResult error(String code, String msg) {
        return new ResponseResult(false, code, msg, null);
    }

}
